package org.kl.bf.repository.basic;

import java.util.Collection;
import java.util.List;

import org.kl.bf.entity.basic.Organization;
import org.kl.bf.repository.BasicRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

public interface OrganizationDao extends BasicRepository<Organization, String>, JpaSpecificationExecutor<Organization> {
	List<Organization> findById(String id);

	List<Organization> findByOrgNo(String orgNo);

	Organization findByOrgName(String orgName);

	/**
	 * 通过父编码查找
	 * 
	 * @param pbsParentNode
	 * @return
	 */
	List<Organization> findByParentOrgId(String parentOrgId);

	@Query("select o from Organization o where o.parentOrgId is null or o.parentOrgId = ''")
	List<Organization> findRoot();

	List<Organization> findByParentOrgIdIn(Collection<String> parentOrgId);

}
